#ifndef V4L2_H
#define V4L2_H

#include <QThread>
#include <thread>
#include <iostream>
#include <QDebug>
extern "C"
{
#include <semaphore.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
#include <string.h>
#include <strings.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/shm.h>
#include <sys/msg.h>
#include <sys/sem.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <fcntl.h>
#include <sys/select.h>
#include <netdb.h>
#include <sys/un.h>
#include <sys/mman.h>
#include <time.h>
#include <termios.h>//串口有关的头文件
#include <poll.h>
#include <pthread.h>//线程有关的头文件
#include <linux/videodev2.h>
#include <sys/ioctl.h>
}
#include <QMutex>
#include <QMutexLocker>



struct usrbuf
{
    void *start;
    int length;
};


class V4L2 : public QThread
{
    Q_OBJECT
public:
    static V4L2 *get()
    {
        static V4L2 v;
        return  &v;
    }
    explicit V4L2(QObject *parent = 0);

    void run();
    int yuyv2rgb(int y, int u, int v);
    int yuyv2rgb0(unsigned char *yuv, unsigned char *rgb, unsigned int width, unsigned int height);

    bool isOn = true;
signals:
    void sigImage(uchar *);
public slots:
    void slotOnOff(bool onOff);
};

#endif // V4L2_H
